home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Sessions / Completions / Completions Source / Synchronization / Atomizer.cp < prev    next >
Encoding:
Text File  |  1998-06-17  |  580 b   |  40 lines  |  [TEXT/CWIE]

  1. // Atomizer.cp
  2.  
  3. #ifndef Atomizer_h
  4. #include "Atomizer.h"
  5. #endif
  6.  
  7. Atomizer::Atomizer()
  8.   : complete( this, &Atomizer::Complete ),
  9.      function( 0 )
  10.   {
  11.   } 
  12.  
  13. Task *Atomizer::operator()( Procedure& theFunction )
  14.   {
  15.     function = &theFunction;
  16.     return this;
  17.   }
  18.  
  19. void Atomizer::Launch()
  20.   {
  21.     Assert( function != 0 );
  22.     if ( DeferredTaskTime::IsNow() )
  23.         Complete( DeferredTaskTime() );
  24.      else
  25.         deferer.Defer( complete );
  26.   }
  27.  
  28. void Atomizer::Kill()
  29.   {
  30.   }
  31.  
  32. void Atomizer::Complete( DeferredTaskTime )
  33.   {
  34.     Assert( function != 0 );
  35.     (*function)();
  36.     function = 0;
  37.     Task::Complete();
  38.   }
  39.  
  40.